package com.app.designpatternslearn.structured.filterpattern

import com.app.designpatternslearn.structured.filterpattern.code.Book
import com.app.designpatternslearn.structured.filterpattern.code.NumberFilterBook
import com.app.designpatternslearn.structured.filterpattern.code.TimeFilterBook
import com.app.designpatternslearn.structured.filterpattern.code.TypeFilterBook
import java.text.SimpleDateFormat

fun main() {

    val books = mutableListOf<Book>()
    val dateFormat = SimpleDateFormat("yyyy-mm-dd HH-mm-ss")
    //归还日期
    val date1 = dateFormat.parse("2018-11-22 15-32-50")
    val book1 = Book("book1", 1, "Computer1", date1.time)
    books.add(book1)
    val date2 = dateFormat.parse("2018-10-22 15-32-50")
    val book2 = Book("book2", 2, "Computer1", date2.time)
    books.add(book2)
    val date3 = dateFormat.parse("2018-12-22 15-32-50")
    val book3 = Book("book3", 3, "Computer2", date3.time)
    books.add(book3)
    val date4 = dateFormat.parse("2019-11-22 15-32-50")
    val book4 = Book("book4", 4, "Computer2", date4.time)
    books.add(book4)
    val date5 = dateFormat.parse("2017-11-22 15-32-50")
    val book5 = Book("book5", 5, "Compute3r", date5.time)
    books.add(book5)
    val date6 = dateFormat.parse("2018-11-22 15-42-50")
    val book6 = Book("book6", 6, "Compute4r", date6.time)
    books.add(book6)
    val date7 = dateFormat.parse("2018-11-22 15-32-51")
    val book7 = Book("book7", 7, "Computer33", date7.time)
    books.add(book7)
    val date8 = dateFormat.parse("2018-11-24 15-32-50")
    val book8 = Book("book8", 8, "Computer22", date8.time)
    books.add(book8)
    val date9 = dateFormat.parse("2018-11-12 15-32-50")
    val book9 = Book("book9", 9, "Computer55", date9.time)
    books.add(book9)
    val date10 = dateFormat.parse("2016-11-22 15-32-50")
    val book10 = Book("book10", 10, "Computer55", date10.time)
    books.add(book10)
    val date11 = dateFormat.parse("2019-11-12 15-32-50")
    val book11 = Book("book11", 11, "Computer55", date11.time)
    books.add(book11)
    val date12 = dateFormat.parse("2018-1-22 15-32-50")
    val book12 = Book("book12", 12, "Computer55", date12.time)
    books.add(book12)

    println("typeFilterBook")
    val typeFilterBook = TypeFilterBook()
    println(typeFilterBook.filter(books))

    println("timeFilterBook")
    val timeFilterBook = TimeFilterBook()
    println(timeFilterBook.filter(books))

    println("numberFilterBook")
    val numberFilterBook = NumberFilterBook()
    println(numberFilterBook.filter(books))

}